package com.dragon.pojo.enums;

import lombok.Getter;
import org.springframework.util.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

@Getter
public enum SupportLanguageEnum {
    JAVA("Java","java"),PYTHON("Python3","python"),CPP("Cpp","cpp"),C("C","c");

    private final String text;

    private final String value;

    SupportLanguageEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    public static SupportLanguageEnum getEnumByValue(String value){
        if(ObjectUtils.isEmpty(value)){
            return null;
        }
        for (SupportLanguageEnum anEnum : SupportLanguageEnum.values()) {
            if(anEnum.value.equals(value)){
                return anEnum;
            }
        }
        return null;
    }

    public static List<String> getValues(){
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }
}
